// let reg = /at/g
// let str = 'ct[bc]ateacatftatbat[bc]at'
// let reg = /.at/gi

// let reg1 = /\[bc\]at/i

// console.log(str.match(reg))

// let text = "mom and dad and baby"
// let pattern = /mom( and dad( and baby)?)?/gi

// console.log(pattern.exec(text))
// let str = '[bc]atwccwill'
// let pattern = new RegExp("\\[bc\\]at", "gi")

// console.log(str.match(pattern))

// let text = "this has been a short summer";

// let reg = /(..)or(.)/gi
// if(reg.test(text)){
//   console.log(RegExp.$1)
//   console.log(RegExp.$2)
// }

// let str = 'a1b2c3d4';
// str = str.replace(/[^a,b,c]\d/g,'x')
// console.log(str)
// let data = '2021-4-22'
// data = data.replace(/[0-9-]/g,'x')
// console.log(data)

// ^ 把@开头的任意字符替换为x
let str = '@123@456ddff'
// str = str.replace(/^@./,'x') // "x23@456ddff"
str = str.replace(/f$/g,'x') 
console.log(str)